<template>
  <div class="up">
    <el-date-picker
      v-model="beginTime"
      type="datetime"
      placeholder="选择日期"
      align="right"
      :picker-options="pickerOptions1"
    >
    </el-date-picker>

    <button @click="submit">提交</button>
  </div>
</template>

<script>
export default {
  methods: {
    submit() {
      console.log({
        deviceKey: this.deviceKey,
        beginTime: this.beginTime,
        endTIme: this.endTime,
        nodeId: this.nodeId,
        isAlarmData: this.isAlarmData,
      });
      this.$axios
        .get("/app/QueryHistoryList", {
          headers: {
            userId: 9372,
          },
          params: {
            deviceKey: 827,
            beginTime: this.beginTime,
            endTIme: this.endTime,
            nodeId: this.nodeId,
            isAlarmData: this.isAlarmData,
          },
        })
        .then((res) => {
          console.log(res);
        });
    },
  },
  data() {
    return {
      pickerOptions1: {
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        ],
      },
      pickerOptions2: {
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        ],
      },
      beginTime: "",
      endTime: "",
      deviceKey: "",
      isAlarmData: -1,
      nodeId: -1,
      options1: [
        {
          value: "827",
          label: "设备1(编号827)",
        },
        {
          value: "23272",
          label: "设备2(编号23272)",
        },
      ],
      options2: [
        {
          value: -1,
          label: "查询全部数据",
        },
        {
          value: 0,
          label: "查询正常数据",
        },
        {
          value: 2,
          label: "查询报警数据",
        },
      ],
    };
  },
};
</script>

<style lang="less" scoped>
</style>